#pragma once

#include "../util/lutils.h"
#include "./manager.h"

namespace lukv {

class driver {
private:
    int id;
    int sock;
    sockaddr_in * paddr;
private:
    std::unordered_map<int, int> cluster_worker_socks;
    std::unordered_map<int, int> cluster_driver_socks;
    std::unordered_map<std::string, std::unordered_set<int>> key_workers;
public:
    explicit driver(int _id);
public:
    ~driver();
public:
    int start();
    std::string handle_cmd(const std::string &);
    int connect_to_worker(int wid);
    int connect_to_driver(int did);
    int send_to_other_drivers(const std::string &);
};

}
